package com.example;

import java.util.Scanner;

public class Demo01 {

    public static void main(String[] args) {
        Student zhangsan = new Student(); // 产生的第一个对象
        System.out.println(zhangsan.name); // null
        zhangsan.name = "张三";
        zhangsan.chinese = 96;
        zhangsan.math = 92;
        System.out.println(zhangsan.name); // 张三
        // 对象调用方法
        zhangsan.zongfen();

        Student lisi = new Student(); // 产生的第二个对象
        lisi.name = "李四";
        lisi.chinese = 85;
        lisi.math = 82;
        lisi.zongfen();
        System.out.println(zhangsan);
        System.out.println(lisi);

        Student wangwu = zhangsan;
        System.out.println(wangwu);
        zhangsan.name = "未知数";
        System.out.println(wangwu.name); // null/张三/未知数
        wangwu.name = "王五";
        System.out.println(zhangsan.name); // 王五
        wangwu = null; // 把wangwu变量执行了空对象
        System.out.println(zhangsan.name); // 王五

        new Student().pingjunfen(); // 匿名对象，后续会自动回收
        Student kunkun = new Student("kunkun", 86, 90);
        kunkun.zongfen();
        kunkun.pingjunfen();
        kunkun.name = "老六";
        kunkun.zongfen();
        System.out.println(kunkun.xinxi()); // 显示属性信息
        System.out.println(kunkun.toString());
        System.out.println(kunkun);
    }
}
